<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Comatible" content="ie=edge">
    <title>分时问候</title>
    <style>
        img {
            width: 300px;
        }
    </style>
</head>

<body>
    <img src="images/zc0g0i0000009fvbaA666.png" alt="">
    <div>上午好</div>
    <script>
        //获取元素
        var img = document.querySelector('img');
        var div = document.querySelector('div');
        //2.得到当前的小时数
        var date = new Date();
        var h = date.getHours();
        //3.判断小时数改变图片和文字信息
        if (h < 12) {
            img.src = 'images/zc0g0i0000009fvbaA666.png';
            div.innerHTML = '亲，上午好哦！';
        } else if (h < 18) {
            img.src = 'images/zc0t0i0000009fpu498E1.png';
            div.innerHTML = '亲，下午好！';
        } else {
            img.src = 'images/zc0v0i0000009fwnfB030.png';
            div.innerHTML = '晚上好！';
        }
    </script>
</body>

</html>